package com.onpositive.knowledge.model.impl;

import java.util.Collection;

import com.onpositive.knowledge.model.IThing;
import com.onpositive.semantic.model.api.command.CompositeCommand;
import com.onpositive.semantic.model.api.property.IProperty;
import com.onpositive.semantic.model.api.property.PropertyAccess;
import com.onpositive.semantic.model.api.property.ValueUtils;

public class BasicInferencer {

	@SuppressWarnings("rawtypes")
	public void infer(Object obj, IProperty prop) {
		CompositeCommand m = new CompositeCommand();
		if (isCommutative(prop)) {
			Iterable<Object> collection = ValueUtils.toCollection(prop
					.getValue(obj));
			for (Object o : collection) {
				if (o instanceof IThing) {
					Collection c = (Collection) ValueUtils.toCollection(prop
							.getValue(o));
					if (!c.contains(obj)) {
						m.addCommand(PropertyAccess.createAddValueCommand(o,
								obj, prop));
					}
				}
			}
		}
	}

	private boolean isCommutative(IProperty prop) {
		return false;
	}
}
